<template>
    <el-form ref="localForm" label-width="100px" :model="localForm" :inline="localInline">
        <el-form-item v-for="item in localFormLabel" :key="item.label" :label="item.label">
            <el-input v-if="item.type==='input'" :placeholder="'请输入' +item.label" v-model="localForm[item.model]" clearable>
            </el-input>
            <el-swich v-if="item.type==='switch'" v-model="localForm[item.model]"></el-swich>
            <el-date-picker v-if="item.type==='date'" type="date" value-format="yyyy-mm-dd" placeholder="选择日期"
                v-model="localForm[item.model]"></el-date-picker>
            <el-select v-if="item.type==='select'" placeholder="请选择" v-model="localForm[item.model]">
                <el-option v-for="item in item.opts" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
            </el-select>

        </el-form-item>
        <el-form-item>
            <slot>
            </slot>
        </el-form-item>
    </el-form>
</template>

<script>
export default {
    name: 'commonForm',
    props: {
        formLabel: Array,
        form: Object,
        inline: Boolean
    },
    data() {
        return {
            localFormLabel:this.formLabel,
            localForm: this.form,
            localInline:this.inline
        }
    }
}

</script>